模仿记事本的简单功能,包括改变字体、查找、改变颜色等等。这里主要实现记事本装载文件、保存文件及快捷键设置等功能。
if (txtBox.Modified == true)
{
DialogResult dr = MessageBox.Show("文件发生变化,是否更改保存?", "注意", MessageBoxButtons.YesNoCancel);
if (dr == DialogResult.Yes)
{
保存SToolStripMenuItem_Click(sender, e);
return;
}
else if (dr == DialogResult.No)
{
return;
}
else if (dr == DialogResult.Cancel)
{
e.Cancel = true;
}
}
---------------- int row = txtBox.GetLineFromCharIndex(txtBox.SelectionStart) 1;
int col = (txtBox.SelectionStart - txtBox.GetFirstCharIndexFromLine(txtBox.GetLineFromCharIndex(txtBox.SelectionStart))) 1;
toolStripStatusLblLocation.Text = "第 " row " 行, 第 " col " 列";
toolStripStatusLblNow.Text = "" DateTime.Now.ToLocalTime();
评论